package com.logic.landseaserver.task;

import java.util.Date;

import com.logic.landseaserver.service.IScheduleService;
import org.apache.commons.lang.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.logic.landseaserver.common.util.DateUtil;
import com.logic.landseaserver.service.IDepositService;

/**
 * Created by Junny on 2017/6/13.
 */
@Component
public class DepositTask{

    private static final Logger log = LoggerFactory.getLogger(DepositTask.class);
    @Autowired
    IDepositService depositService;

    @Autowired
    private IScheduleService iScheduleService;

    @Scheduled(cron = "0 0 0 * * ?")
    public void queryComeDue() {
        //月账单
        boolean cuteFlag = iScheduleService.cuteSchedule();
        if(cuteFlag){
            //定金过期处理
            log.info("Task for Deposit comeDue start");
            String comeDueDate = DateUtil.getInstence().convertDate(DateUtils.addDays(new Date(), -1));
            depositService.cancleComeDueDeposit(comeDueDate);
            log.info("Task for Deposit comeDue end");
        }
    }

}
